Rename users

HI,
I am looking to rename the user names for all users in database.
So, I made up the following dxl code to see if it can be done.
But the code doesn't do anyhthing, the user remains "test_user"

string new_name = "new_test_user"
string old_name = "test_user"

loadDirectory()
User u = null
if(existsUser old_name) {
u = find old_name
loadUserRecord u
set(u, "name", new_name)
saveUserRecord u

}
saveDirectory()

Does anybody know why?
ostanescu - Mon Jul 23 14:13:59 EDT 2012

Re: Rename users
llandale - Mon Jul 23 14:41:55 EDT 2012

You need to use:
  • u.name = new_name
The "set" command is for custom attributes, in this case you have set a custom attribute called "name" to the user, might as well have called it "IngoreMe". That attribute won't matter unless later someone else uses it (which is unlikely), but you should go ahead and delete it
  • for u in userList do{delete(u, "user")}

-Louie

Re: Rename users
ostanescu - Mon Jul 23 16:45:19 EDT 2012

llandale - Mon Jul 23 14:41:55 EDT 2012
You need to use:

  • u.name = new_name
The "set" command is for custom attributes, in this case you have set a custom attribute called "name" to the user, might as well have called it "IngoreMe". That attribute won't matter unless later someone else uses it (which is unlikely), but you should go ahead and delete it
  • for u in userList do{delete(u, "user")}

-Louie

Thank you for the quick response.
I was only playing with one user for testing.

Now, i can process all users.